import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
import fire from '@dfeidao/atom-web/msg/fire';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';
import hide_loading from '../../atom/hide-loading';
import show_loading from '../../atom/show-loading';
export default async function a002(fd: IFeidaoAiBrowserComponent) {
	//  保存
	set(fd, 'sss', 1);

	const pk_val = get(fd, 'pk_val');
	const search_field_val = get(fd, 'search_field_val');
	const role_no = get(fd, 'role_no');
	const ff = get(fd, 'ff');
	const productid = get(fd, 'productid');
	if (!role_no) {
		error('角色编号为空');
		return;
	}
	if (!pk_val) {
		error('请选择一行数据');
		return;
	}
	if (!search_field_val) {
		error('请选择一行数据');
		return;
	}
	const query = {
		pk_val,
		search_field_val,
		role_no,
		productid
	};
	show_loading();
	const res = await nodejs<{ ret: string; msg: string; }>('roler/zj-000005/s002', query);
	hide_loading();
	if (res.ret === 'success') {
		fire('zj-000004', 'ec-002', role_no, ff);
		fire('zj-000005', 'eu-001');
		success('保存成功');
	} else {
		error(res.msg);
	}
}
